home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_58_CycleMeContinuous.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  4.2 KB  |  117 lines

  1. property enabled, membermin, membermax, ImageCastLib, CycleStyle, tracking, goingDown, CurrentState, numstates, name
  2.  
  3. on mouseDown me
  4.   set tracking to 1
  5.   bumpstate_intern(me)
  6. end
  7.  
  8. on prepareFrame me
  9.   if tracking then
  10.     bumpstate_intern(me)
  11.   end if
  12. end
  13.  
  14. on mouseUp me
  15.   set tracking to 0
  16. end
  17.  
  18. on setstate me, statenum
  19.   if the enabled of me then
  20.     if statenum > the numstates of me then
  21.       set statenum to the numstates of me
  22.     else
  23.       if statenum < 1 then
  24.         set statenum to 1
  25.       end if
  26.     end if
  27.     set the member of sprite the spriteNum of me to member (the membermin of me + statenum - 1) of castLib ImageCastLib
  28.   end if
  29. end
  30.  
  31. on setGoingDown me, value
  32.   set the goingDown of me to value
  33. end
  34.  
  35. on SetCycleStyle me, value
  36.   set the CycleStyle of me to value
  37. end
  38.  
  39. on bumpstate_intern me
  40.   if the enabled of me then
  41.     if the CycleStyle of me = #repeat then
  42.       if not (the goingDown of me) then
  43.         set curr to the CurrentState of me + 1
  44.         if curr > the numstates of me then
  45.           set curr to 1
  46.         end if
  47.       else
  48.         set curr to the CurrentState of me - 1
  49.         if curr < 1 then
  50.           set curr to the numstates of me
  51.         end if
  52.       end if
  53.     else
  54.       if not (the goingDown of me) then
  55.         set curr to the CurrentState of me + 1
  56.         if curr > the numstates of me then
  57.           set curr to curr - 2
  58.           set the goingDown of me to 1
  59.         end if
  60.       else
  61.         set curr to the CurrentState of me - 1
  62.         if curr < 1 then
  63.           set curr to 2
  64.           set the goingDown of me to 0
  65.         end if
  66.       end if
  67.     end if
  68.     set the CurrentState of me to curr
  69.     setstate(me, curr)
  70.   end if
  71. end
  72.  
  73. on beginSprite me
  74.   set tracking to 0
  75.   set membermin to the memberNum of member membermin
  76.   set membermax to the memberNum of member membermax
  77.   puppetSprite(the spriteNum of me, 1)
  78.   set the enabled of me to 1
  79.   set the numstates of me to the membermax of me - the membermin of me + 1
  80.   set the CurrentState of me to the memberNum of sprite the spriteNum of me - the membermin of me + 1
  81.   set the ImageCastLib of me to the number of castLib the castLibNum of sprite the spriteNum of me
  82.   setstate(me, the CurrentState of me)
  83. end
  84.  
  85. on endSprite me
  86.   puppetSprite(the spriteNum of me, 0)
  87. end
  88.  
  89. on getPropertyDescriptionList
  90.   set description to [:]
  91.   if the currentSpriteNum = 0 then
  92.     set cycledefault to 0
  93.   else
  94.     set memref to the member of sprite the currentSpriteNum
  95.     set castLibNum to the castLibNum of memref
  96.     set cycledefault to member the memberNum of member memref of castLib castLibNum
  97.   end if
  98.   addProp(description, #name, [#comment: "Item Name:", #format: #symbol, #default: #MultiState_1])
  99.   addProp(description, #membermin, [#comment: "First Image:", #format: #member, #default: cycledefault])
  100.   addProp(description, #membermax, [#comment: "Last Image:", #format: #member, #default: cycledefault])
  101.   addProp(description, #CycleStyle, [#comment: "Cycle Style:", #format: #symbol, #range: [#repeat, #Reverse], #default: #repeat])
  102.   addProp(description, #goingDown, [#comment: "Reverse Order:", #format: #boolean, #default: 0])
  103.   return description
  104. end
  105.  
  106. on getBehaviorDescription
  107.   return "Prepares a sprite to use a Series of adjacent Bitmap castmembers to represent an set of mutually exclusive states that the user can cycle through.  See below for usage.  " & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Item Name - ( optional ) name of this control." & RETURN & "ΓÇó First Image - number of first castmember in the sequence." & RETURN & "ΓÇó Last Image  - number of last castmember in the sequence." & RETURN & "ΓÇó Cycle Mode - specifies how images in cycle are repeated on subsequent iterations. The Repeat mode repeats the same sequence.  The Reverse mode cycles back through the sequence in reverse order." & RETURN & "ΓÇó Reverse Order - proceed from last to first image by default." & RETURN & "MESSAGES:" & RETURN & "ΓÇó CycleState - advance to the next image in the sequence, or the previous image, if the GoingDown property is true. & RETURN & "ΓÇó SetState state_number - advance directly to position state_number in the sequence."
  108. end
  109.  
  110. on getAssocMembers
  111.   set myPropList to []
  112.   repeat with x = membermin + 1 to membermax
  113.     add(myPropList, member x of castLib ImageCastLib)
  114.   end repeat
  115.   return myPropList
  116. end
  117.